import { getOrderDetail } from "../../services/modules/user"
import { getOrder } from "../../services/modules/user"
const state = {
    orderList: [],
    orderItemDtos: [],
    remarks: "",
    actualTotal: 0,
    userAddrDto: null,
    orderNumber: "",
    createTime: "",
    status: 0,
    productTotalAmount: '',
    transfee: '',
    reduceAmount: '',
    actualTotal: '',
    prodid: ''
};
const getters = {};
const mutations = {
    update(state, payload) {
        for (let key in payload) {
            state[key] = payload[key];
        }
    }
};
const actions = {
    async getActionsOrder({
        commit
    }, payload) {

        let result = await getOrder(payload);
        console.log("result???????????",result);
        commit('update', { orderList: JSON.parse(JSON.stringify(result.records)) })

    },
    async getOrederDel({ commit }, payload) {
        let res = await getOrderDetail(payload)
        console.log('resss', res)
        commit('update', {
            orderNumber: payload,
            actualTotal: res.actualTotal,
            userAddrDto: res.userAddrDto,
            remarks: res.remarks,
            orderItemDtos: res.orderItemDtos,
            createTime: res.createTime,
            status: res.status,
            productTotalAmount: res.orderItemDtos[0].productTotalAmount,
            transfee: res.transfee,
            reduceAmount: res.reduceAmount,
            actualTotal: res.actualTotal,
        })
    },
};

export default {
    namespaced: true,
    modules: {},
    state,
    getters,
    mutations,
    actions,
};